package com.itcast.activiti.controller;


import cn.itcast.ic.common.bean.Response;
import com.itcast.activiti.entity.ActIdProcess;
import com.itcast.activiti.service.IActIdProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 自定义流程类别 前端控制器
 * </p>
 *
 * @author itcast
 * @since 2021-03-03
 */
@RestController
@RequestMapping("/process")
public class ActIdProcessController {
    @Autowired
    private IActIdProcessService iActIdProcessService;

    /**
     * 自定义流程类别
     */
    @GetMapping("/list")
    public Response listActIdProcess(@RequestParam(required = false) Integer actIdProcessId) {
        return Response.success(iActIdProcessService.listActIdProcess(actIdProcessId));
    }

    @GetMapping(path = "/get/{id}")
    public Response getApproveField(@PathVariable("id") Integer id) {
        return Response.success(iActIdProcessService.getActIdProcess(id));
    }

    @PostMapping(value = "/add")
    public Response addApproveField(@RequestBody ActIdProcess actIdProcess) {
        return Response.success(iActIdProcessService.addActIdProcess(actIdProcess));
    }

    @PostMapping(value = "/edit")
    public Response editApproveField(@RequestBody ActIdProcess actIdProcess) {
        return Response.success(iActIdProcessService.editActIdProcess(actIdProcess));
    }

    @DeleteMapping(path = "/del/{id}")
    public Response delApproveField(@PathVariable("id") Integer id, @RequestParam(required = false) String deletedBy) {
        return Response.success(iActIdProcessService.delActIdProcess(id, deletedBy));
    }

}

